<?php

namespace Boosen\Admin\EmailAlert\Lib;

use App\Models\Issue;

class NewIssuePublishTemplate extends Template
{

    private $issue;

    public function __construct($id = 0)
    {
        if ($id) {
            $this->issue = Issue::find($id);
        } else {
            $this->issue = (new Issue())->currentIssue();
        }
    }


    public function subject()
    {
        return '《动物学研究》' . $this->issue->year . '年' . $this->issue->issue . '期 最新目次';
    }

	public function body()
	{

		$currentIssue = $this->issue;
		$articles = $currentIssue->articles;
		$html = '<p style="margin-bottom:0px;">
    <img alt="" title="" src="' . asset('/images/zr_header.jpg') . '" width="1096" height="210"/>
</p>
<p style="width: 1086px;background-color:#076919; margin-top:-5px; padding: 10px 5px">
    <span style="font-size: 14px; color: #fff;">欢迎访问《动物学研究》网站（<a style="color: #fff;text-decoration: none;" href="www.zoores.ac.cn" target="_blank">www.zoores.ac.cn</a>）,&nbsp; 浏览更多精彩文章。</span><span style="color: #fff;float:right; font-size: 12px;">[<a target="_blank" href="http://www.zoores.ac.cn/EN/column/column79.shtml" style="color: #fff;text-decoration: none;"><strong>期刊简介</strong></a>] [<a target="_blank" style="color: #fff;text-decoration: none;" href="http://www.zoores.ac.cn/EN/column/column117.shtml"><strong>投稿须知</strong></a>] [<a style="color: #fff;text-decoration: none;" href="http://www.zoores.ac.cn/EN/column/column83.shtml" target="_blank"><strong>联系我们</strong></a>]</span>
 &nbsp; &nbsp; &nbsp; &nbsp;
</p>
<p>
    <br/>
</p>
<table width="1096">
    <tbody>
        <tr class="firstRow">
            <td style="border-width: 1px; border-style: solid; border-color:#ccc;padding: 10px;background-color: #f4f4f4;" width="896" valign="top">
                <p>
                    <span style="font-size: 14px;">尊敬的xxxxxxx老师： 您好！</span>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </p>
                <p style="text-indent: 2em;">
                    <span style="font-size: 14px;">很高心通过E-mail alert为您推荐《动物学研究》最新一期的电子目次， 点击目次中的摘要、HTMl和PDF, 可以阅读该问的摘要、HTMl和全文。您也可以登录本刊网站（http://www.zoores.ac.cn），查看更多已发表的文章。欢迎阅读并引用！欢迎您向本刊投稿或推荐优秀稿件，也欢迎您提出宝贵意见！</span>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </p>
                <p style="text-indent: 0em;">
                    <span style="font-size: 14px;float:right;">《江西农业大学学报》编辑部<br/></span>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </p>
            </td>
            <td colspan="1" rowspan="3" width="210" valign="top">
                <p style="text-align:center; border: 1px solid #ddd; padding: 10px;color:#fff;background-color:#076919;margin-bottom:0px;">
                    <strong>本 刊 信 息</strong>
                </p>
                <p style="text-align:center; border-right: 1px solid #ddd;border-left: 1px solid #ddd; border-bottom: 1px dashed #ddd; padding: 10px;margin:0px;">
                    <img src="' . asset('uploads/' . $currentIssue->cover) . '" width="158" height="208"/>
                </p>
                <p style="text-align:center;border-right: 1px solid #ddd;border-left: 1px solid #ddd;border-bottom: 1px dashed #ddd;padding: 10px;margin:0px;">
                    <img src="' . asset('images/2016.jpg') . '" width="158" height="158"/>
                </p>
                <p style="font-size:12px; border-right: 1px solid #ddd;border-left: 1px solid #ddd; padding: 10px 10px 5px 30px;margin:0px;">
                    <strong>刊名：</strong>动物学研究
                </p>
                <p style="font-size:12px; border-right: 1px solid #ddd;border-left: 1px solid #ddd; padding: 5px 10px 5px 30px;margin:0px;">
                    <strong>主办：</strong>动物学研究
                </p>
                <p style="font-size:12px; border-right: 1px solid #ddd;border-left: 1px solid #ddd; padding: 5px 10px 5px 30px;margin:0px;">
                    <strong>出版周期：</strong>双月
                </p>
                <p style="font-size:12px; border-right: 1px solid #ddd;border-left: 1px solid #ddd; padding: 5px 10px 5px 30px;margin:0px;">
                    <strong>出版单位：</strong>科学出版社
                </p>
                <p style="font-size:12px; border-right: 1px solid #ddd;border-left: 1px solid #ddd; padding: 5px 10px 5px 30px;margin:0px;">
                    <strong>开本：</strong>大16开
                </p>
                <p style="font-size:12px; border-right: 1px solid #ddd;border-left: 1px solid #ddd; padding: 5px 10px 5px 30px;margin:0px;">
                    <strong>ISSN：</strong>1000-2286
                </p>
                <p style="font-size:12px; border-right: 1px solid #ddd;border-left: 1px solid #ddd; padding: 5px 10px 5px 30px;margin:0px;">
                    <strong>CN：</strong>36-1028/S
                </p>
                <p style="font-size:12px; border-right: 1px solid #ddd;border-left: 1px solid #ddd; padding: 5px 10px 5px 30px;margin:0px;">
                    <strong>邮发代号：</strong>44-102（国内）
                </p>
                <p style="font-size:12px; border-right: 1px solid #ddd;border-left: 1px solid #ddd;border-bottom: 1px solid #ddd; padding: 5px 10px 20px 30px;margin:0px;">
                    <strong>创刊时间：</strong>1979
                </p>
            </td>
        </tr>
        <tr>
            <td width="896" valign="top"></td>
        </tr>
        <tr>
            <td style="border-width: 1px; border-style: solid;border-color:#ccc;padding: 20px;" width="896" valign="top">
                <h3 style="font-size: 20px; font-weight: bold; padding: 0px 4px 0px 0px; text-align: center; margin: 10px 0px 20px; color:#000;">
                    ' . $currentIssue->year . '年' . $currentIssue->issue . '期 最新目次
                </h3>';

        foreach ($articles as $article) {
        	$html .= '<p style="padding: 10px 0px 5px 30px;font-size:14px; background-color:#f4f4f4;margin:0px;">
                    <a style="text-decoration: none;display:inline;font-size:15px; color:#000;" target="_blank" href="' . route('article.index', ['id' => $article->id]) .  '"><strong>' . $article->title . '</strong></a> - <span style="font-size:12px;display:inline; color:#000;">' . $article->pureAuthorList() . '</span>
                </p>
                <p style="padding: 5px 0px 5px 30px;font-size:14px;background-color:#f4f4f4;margin:0px;">
                    <strong>Abstract:</strong>&nbsp;' . $article->abstract . '
                </p>
                <p style="padding-left: 30px;border-top:1px dashed #000;background-color:#f4f4f4;margin:0px;">
                    <br/>
                </p>';
        }

        $html .= '</td>
        </tr>
    </tbody>
</table>
<p style="font-size: 12px; margin: 0px;">
    版权所有© 《动物学研究》编辑部 &nbsp;Tel: 0871-65199026 内线: 8224<br/>地址:昆明市教场东路32号 中国科学院昆明动物研究所 &nbsp;邮编：330045
</p>';

		return $html;
	}
}